package com.e_manager.soft.emanager.service.impl;

import com.e_manager.soft.emanager.entity.UserEquipment;
import com.e_manager.soft.emanager.entity.parameter.UserEquipmentParameter;
import com.e_manager.soft.emanager.idao.UserEquipmentDao;
import com.e_manager.soft.emanager.service.UserEquipmentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @author : lip[lip4051@163.com]
 * @create : 2018/3/21 0021 上午 11:02
 */
@Service
public class UserEquipmenteServiceImpl implements UserEquipmentService {
    @Autowired
    private UserEquipmentDao userEquipmentDao;

    @Override
    public PageInfo<UserEquipment> findUserEquipmentByPage(UserEquipmentParameter userEquipmentParameter) {
        /**
         * @author lip
         * @description 用户设备信息数据查询
         * @method findUserEquipmentByPage
         * @param []
         * @returnType void
         * @date 2018/3/21 0021 上午 11:03
         */
        PageHelper.startPage(userEquipmentParameter.getPageNumber(), userEquipmentParameter.getPageSize());
        List<UserEquipment> list = userEquipmentDao.findUserEquipmentByPage(userEquipmentParameter);
        return new PageInfo<>(list);
    }

    @Override
    public int getUserEquipmentByNameAndId(UserEquipment userEquipment) {
        int count = userEquipmentDao.getUserEquipmentByNameAndId(userEquipment);
        return count;
    }

    @Transactional
    @Override
    public void insertUserEquipment(UserEquipment userEquipment) {
        userEquipmentDao.insertUserEquipment(userEquipment);
    }

    /**
     * 查询系统信息
     *
     * @param userEquipment
     */
    @Override
    public void updateUserEquipment(UserEquipment userEquipment) {
        userEquipmentDao.updateUserEquipment(userEquipment);
    }
}
